local Lua__xz = fk.CreateSkill {

    name = "Lua__xz",
}
  
  Fk:loadTranslationTable{
    
      ["Lua__xz"] = "孝子",
      [":Lua__xz"] = "每轮开始时，你令一名非主公角色身份变为与你相同。你受到伤害时这些角色摸2张牌。",
      ["#Lua__xz-use"] = "孝子：你可令一名非主公角色身份变为与你相同。",
      ["@@Lua__xz_original_role"] = "孝子",
  }
  

Lua__xz:addEffect(fk.TurnStart, {
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(Lua__xz.name) and target == player
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local enemies = {}
        for _, p in ipairs(room:getOtherPlayers(player)) do
            if p.role ~= "lord" then
              table.insert(enemies, p)
            end
          end

          local targets = room:askToChoosePlayers(player, {
            targets = enemies,
            min_num = 1,
            max_num = 1,
            prompt = "#Lua__xz-use",
            skill_name = Lua__xz.name,
            cancelable = true,
          })
          if #targets > 0 then
            event:setCostData(self, {target = targets[1]})
            return true
        end 
    end,
      on_use = function (self, event, target, player, data)
         local room = player.room
         local target = event:getCostData(self).target
         room:setPlayerMark(target, "@@Lua__xz_original_role", 1)
         room:setPlayerProperty(target, "role", player.role)
         room:notifyProperty(target, target, "role")
         room:broadcastProperty(target, "role")
      end,
})

Lua__xz:addEffect(fk.DamageInflicted, {
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(Lua__xz.name) and target == player
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        for _, p in ipairs(room:getOtherPlayers(player)) do
            if p:getMark("@@Lua__xz_original_role") > 0 then
                room:drawCards(p, 2, Lua__xz.name)
            end
        end
    end,
})

  
return Lua__xz